
LOCAL_PATH    := $(call my-dir)
EXTERNAL_PATH := ../../../../../External
ENGINE_PATH   := ../../../../../Engine
UXSTL_PATH    := ../../../../../../../ux_stl/trunk
STD_PATH	  := $(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8
STDLIB_PATH   := $(STD_PATH)/libs/armeabi-v7a
#------------------------------------------------------------------------------


# Build FreeType
include $(CLEAR_VARS)

LOCAL_MODULE := FreeType

MY_FLAGS_RELEASE := \
	-fvisibility=hidden \
	-finline-functions-called-once \
	-fdata-sections \
	-ffunction-sections \
	-ffast-math \
	-funroll-loops \
	-fno-stack-protector \
	-O3 \
	-DNDEBUG

MY_FLAGS_DEBUG := \
	-D_DEBUG \
	-g \
	-pipe
	

LOCAL_CFLAGS += \
	-fno-rtti \
	-Werror=return-type


ifeq ($(NDK_DEBUG), 1)
	LOCAL_CFLAGS += $(MY_FLAGS_DEBUG)
else
	LOCAL_CFLAGS += $(MY_FLAGS_RELEASE)
endif


LOCAL_C_INCLUDES := -I$(LOCAL_PATH)/$(EXTERNAL_PATH)/FreeType/include \
					-I$(LOCAL_PATH)/$(EXTERNAL_PATH)/FreeType/include/freetype/config

LOCAL_SRC_FILES := $(EXTERNAL_PATH)/FreeType-And/freetype.c

include $(BUILD_STATIC_LIBRARY)
#------------------------------------------------------------------------------



#ifdef BOX2D
# Build Box2D
include $(CLEAR_VARS)

LOCAL_MODULE := Box2D

MY_FLAGS_RELEASE := \
	-fvisibility=hidden \
	-finline-functions-called-once \
	-fdata-sections \
	-ffunction-sections \
	-ffast-math \
	-funroll-loops \
	-fno-stack-protector \
	-O3 \
	-DNDEBUG

MY_FLAGS_DEBUG := \
	-D_DEBUG \
	-g \
	-pipe
	
LOCAL_CFLAGS += \
	-fno-rtti \
	-Werror=return-type \
	-DBOX2D_BUILD


ifeq ($(NDK_DEBUG), 1)
	LOCAL_CFLAGS += $(MY_FLAGS_DEBUG)
else
	LOCAL_CFLAGS += $(MY_FLAGS_RELEASE)
endif


LOCAL_C_INCLUDES := \
	$(STD_PATH)/include \
	$(STD_PATH)/libs/armeabi-v7a/include \
	$(LOCAL_PATH)/$(EXTERNAL_PATH)/Box2D/..


LOCAL_SRC_FILES := \
	$(EXTERNAL_PATH)/Box2D/Collision/b2BroadPhase.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2CollideCircle.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2CollideEdge.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2CollidePolygon.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2Collision.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2Distance.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2DynamicTree.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/b2TimeOfImpact.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/Shapes/b2ChainShape.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/Shapes/b2CircleShape.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/Shapes/b2EdgeShape.cpp \
	$(EXTERNAL_PATH)/Box2D/Collision/Shapes/b2PolygonShape.cpp \
	$(EXTERNAL_PATH)/Box2D/Common/b2BlockAllocator.cpp \
	$(EXTERNAL_PATH)/Box2D/Common/b2Draw.cpp \
	$(EXTERNAL_PATH)/Box2D/Common/b2Math.cpp \
	$(EXTERNAL_PATH)/Box2D/Common/b2Settings.cpp \
	$(EXTERNAL_PATH)/Box2D/Common/b2Timer.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2Body.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2ContactManager.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2Fixture.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2Island.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2World.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/b2WorldCallbacks.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2CircleContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2Contact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2ContactSolver.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Contacts/b2PolygonContact.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2DistanceJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2FrictionJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2GearJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2Joint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2MouseJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2PulleyJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2RopeJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2WeldJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Dynamics/Joints/b2WheelJoint.cpp \
	$(EXTERNAL_PATH)/Box2D/Rope/b2Rope.cpp \


LOCAL_STATIC_LIBRARIES += $(STDLIB_PATH)/libgnustl_static.a

include $(BUILD_STATIC_LIBRARY)
#endif BOX2D
#------------------------------------------------------------------------------



# Build EXGEN-ES
include $(CLEAR_VARS)

MY_SOURCES  := $(ENGINE_PATH)/Main/Android.Main.cpp

MY_INCLUDES := \
	-I$(LOCAL_PATH)/$(ENGINE_PATH) \
	-I$(LOCAL_PATH)/$(EXTERNAL_PATH) \
	-I$(LOCAL_PATH)/$(UXSTL_PATH) \
	-I$(LOCAL_PATH)/$(EXTERNAL_PATH)/FreeType/include \
	-I$(LOCAL_PATH)/$(EXTERNAL_PATH)/FreeType/include/freetype

MY_LIBRARIES := \
	-L$(SYSROOT)/usr/lib \
	-ldl \
	-llog \
	-landroid \
	-lEGL \
	-lOpenSLES

MY_STATIC_LIBS := FreeType

#ifdef BOX2D
MY_STATIC_LIBS += Box2D
#endif BOX2D
	
MY_C_FLAGS := \
	-std=c++11 \
	-fno-rtti \
	-Werror=return-type \
	-Werror=sequence-point \
	-Werror=char-subscripts \
	-Werror=switch \
	-Werror=switch-enum \
	-Werror=missing-braces \
	-Werror=missing-include-dirs \
	-Werror=parentheses \
	-Werror=unknown-pragmas \
	-Werror=enum-compare \
	-Werror=sizeof-pointer-memaccess \
	-Werror=address \
	-Werror=sign-compare \
	-Wunused \
	-Wuninitialized \
	-Wfloat-equal \
	-Wvolatile-register-var \
	-Wignored-qualifiers \
	-Wtype-limits \
	-DENGINE_META_DATA \
	-DUX_ZLIB_DISABLE \
	-DUX_LZMA_DISABLE
	
MY_FLAGS_RELEASE := \
	-fvisibility=hidden \
	-finline-functions-called-once \
	-fdata-sections \
	-ffunction-sections \
	-ffast-math \
	-funroll-loops \
	-fno-stack-protector \
	-O3 \
	-flto \
	-DNDEBUG \
	-D__UX_FAST__

MY_FLAGS_DEBUG := \
	-D__UX_DEBUG__ \
	-D_DEBUG \
	-g \
	-pipe \
	-Warray-bounds


LOCAL_MODULE    := UXGENES

LOCAL_CFLAGS     += $(MY_C_FLAGS)
LOCAL_C_INCLUDES := $(MY_INCLUDES)
LOCAL_SRC_FILES  := $(MY_SOURCES)
LOCAL_LDLIBS     := $(MY_LIBRARIES)


ifeq ($(NDK_DEBUG), 1)
	LOCAL_CFLAGS   += $(MY_FLAGS_DEBUG)
else
	LOCAL_CFLAGS   += $(MY_FLAGS_RELEASE)
endif

	
LOCAL_STATIC_LIBRARIES := $(MY_STATIC_LIBS)

include $(BUILD_SHARED_LIBRARY)
#------------------------------------------------------------------------------

